<?php
/**
 * Created by PhpStorm.
 * User: xu42
 * Date: 16-9-7
 * Time: 下午1:24
 */

namespace App\Library;


class Weather
{
    public static function info( $cityname )
    {
//        $key   = config( 'juhe.weather.key' );
//        $dtype = config( 'juhe.weather.dtype' );

        $key = '6185e1a07642919c90560ddc957a6963';
        $dtype = 'json';

        $url   = "https://op.juhe.cn/onebox/weather/query?key=$key&dtype=$dtype&cityname=$cityname";
        $ch    = curl_init();
        curl_setopt( $ch, CURLOPT_URL, $url );
        curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
        $webPage = curl_exec( $ch );
        curl_close( $ch );
        return json_decode( $webPage, true );
    }
}